<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <div></div>
    <div></div>
    <div></div>
    <div></div>
    <div></div>
    <div></div>
    <div></div>
    <div></div>
    <script>
      // Array.of
      /* // 数组new Array()如果只传递一个参数，表示该数组的长度，多个参数，表示数组内部的值。
      const arr = Array.of(1, 2, 3, 4, 5);
      // const arr1 = new Array(1, 2, 3, 4, 5);
      console.log(arr, arr1); */

      // Array.from
      /* const divsEl = document.querySelector("div");
      console.log(Array.from(divsEl)); */

      // find
      const arr = [
        { name: "a", id: 1 },
        { name: "b", id: 2 },
        { name: "c", id: 3 },
        { name: "d", id: 4 },
        { name: "e", id: 5 },
      ];

      // filter查找多个，find只查找一个, 没有找到返回undefined
      // console.log(arr.find((o) => o.id === 5));
      // 没有找到返回-1
      // console.log(arr.findIndex((o) => o.id === 5));

      // Array.prototype.fill(val)
      // console.log(new Array(100).fill("abc"));

      // arr.copyWithin(2);
      // arr.copyWithin(2, 1);
      // arr.copyWithin(2, 1, 3);
      // console.log(arr);

      // Array.prototype.includes(val), Array.prototype.indexOf(val): 传递的是查找的值，而不是回调函数
      /* console.log(arr.indexOf((o) => o.id === 5));
      console.log(
        arr.includes((o) => {
          console.log(o);
          return o.id === 5;
        })
      ); */
    </script>
  </body>
</html>
